package com.icoolkj.ms.auth.feign;

import com.icoolkj.ms.api.auth.feign.AccountManageFeignClient;
import com.icoolkj.ms.auth.service.IAuthAccountService;
import com.icoolkj.ms.common.core.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author icoolkj
 * @version 1.0
 * @description 账户管理Feign控制器
 * @createDate 2025/02/04 16:33
 */
@RestController
@Hidden
public class AccountManageFeignController implements AccountManageFeignClient {

    @Autowired
    private IAuthAccountService authAccountService;

    @Override
    @DeleteMapping("/feign/account/delete/{uid}")
    public ServerResponseEntity<Integer> deleteByUid(@PathVariable("uid") Long uid) {
        int rows = authAccountService.deleteByUid(uid);
        return rows > 0 ? ServerResponseEntity.success(rows) : ServerResponseEntity.fail("删除失败");
    }

    @Override
    @PostMapping("/feign/account/batch/delete")
    public ServerResponseEntity<Integer> batchDeleteByUids(@RequestBody Long[] uids) {
        int rows = authAccountService.batchDeleteByUids(uids);
        return rows > 0 ? ServerResponseEntity.success(rows) : ServerResponseEntity.fail("批量删除失败");
    }
}